#include <vector>
#include <iostream>

using namespace std;

vector<vector<int>> yangHuiTriangle(int level){
    vector<vector<int>> result {{1}};

    for(int i = 1; i < level; ++i){
        vector<int> tmp(i + 1, 0);
        for(int j = 0; j < i + 1; ++j){
            if(j == 0 || j == tmp.size()-1){
                tmp[j] = 1;
            }
            else{
                tmp[j] = result[i - 1][j - 1] + result[i - 1][j];
            }
        }

        result.push_back(tmp);
    }
    return result;
}

int main(int argc, char const *argv[])
{
    auto result = yangHuiTriangle(5);

    for (auto v : result)
    {
        for (int n : v)
        {
            cout << n << " ";
        }

        cout << endl;
    }
    return 0;
}
